package com.elinkway.infinitemovies.async;

import android.content.Context;
import android.os.Bundle;

import com.elinkway.infinitemovies.bean.LiveClassifyInfos;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.LiveChannelParser;
import com.lvideo.http.bean.LVideoDataHull;

/**
 * 带参数请求直播数据
 */
public class RequestLiveChannelTask extends MoviesHttpAsyncTask<LiveClassifyInfos> {

    private Bundle mParams = new Bundle();

    public RequestLiveChannelTask(Context context) {
        super(context);
    }

    private RequestResultListener<LiveClassifyInfos> mListener;

    @Override
    public LVideoDataHull<LiveClassifyInfos> doInBackground() {
        return MoviesHttpApi.requestLiveChannelInfo(new LiveChannelParser(), mParams);
    }

    @Override
    public void onPostExecute(int updateId, LiveClassifyInfos result) {
        if (mListener != null) {
            mListener.onRequestSuccess(updateId, result);
        }
    }

    @Override
    public void netNull() {
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void netErr(int updateId, String errMsg) {
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void dataNull(int updateId, String errMsg) {
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    public void setmListener(RequestResultListener<LiveClassifyInfos> mListener) {
        this.mListener = mListener;
    }

    public void setParams(Bundle mParams) {
        this.mParams = mParams;
    }

    public void setParamPage(int mParamPage) {
        mParams.putString("pageindex", String.valueOf(mParamPage));
    }

    public void setParamPageSize(int mParamPageSize) {
        mParams.putString("pagesize", String.valueOf(mParamPageSize));

    }

    public void setParamChannel(String mParamChannel) {
        mParams.putString("channel", mParamChannel);
    }

}
